<template>
	<view class="container">
		<view class="fiexd-top">
			<view class="header">
				<view class="arrow" @tap="$back()"><image src="../../../static/images/arrow_left.png" mode="aspectFit"></image></view>
				<view class="text f36 cfff">员工角色选择</view>
				<view class="save f36 cfff" @tap="saveBtn()">保存</view>
			</view>
		</view>

		<view style="height: 130upx;"></view>
		<view class="tipBox f28 c666"><text>每一个员工可以设置一种或多种角色</text></view>

		<view class="listBox">
			<view class="list-item" v-for="(i, index) in list" :key="index">
				<view class="checkbox" @click.stop="changeImg(index)">
					<image src="../../../static/images/checkbox.png" mode="aspectFit" v-show="!i.isok" ></image>
					<image src="../../../static/images/checkbox-on.png" mode="aspectFit" v-show="i.isok"></image>
				</view>
				<view class="text">
					<view class="name f32 c333">{{ i.name }}</view>
					<view class="brief f28 c666">{{ i.brief }}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			list: '',
			listTwo:''
		};
	},
	onShow() {
		this.list = [
			{ name: '店铺管理员', brief: '负责店铺所有事务管理', lit: 1 },
			{ name: '销售员', brief: '负责货品销售、客户管理等', lit: 2 },
			{ name: '创库管理员', brief: '负责仓库管理、采购，盘点、上货、发货等', lit: 3 }
		];
		this.list.map((item, index) => {
			this.list[index].isok = false;
		});
	},
	methods: {
		ad() {
			// console.log(this.list);
			// c=this.list.filter(item=>{
			// 	return	item.isok==false
			// 	})
			// 	console.log(c);
		},
		changeImg(index) {
			this.list[index].isok = !this.list[index].isok;
			this.$set(this.list, index, this.list[index]);
		},
		saveBtn() {
			this.list.filter(item => {
				return item.isok == true;
			});
			console.log(this.listTwo);
			uni.setStorageSync('list', this.listTwo);
			this.$back();
		}
	},
	watch: {
		list(newval) {
			let c;
			c = this.list.filter(item => {
				return item.isok == true;
			});
			immediate: true;
			// console.log(c);
			this.listTwo=c
		}
	}
};
</script>

<style lang="scss">
page {
	background-color: #f7f4f8;
}

.status_bar {
	height: var(--status-bar-height);
	width: 100%;
	background-color: #ffffff;
}

.top_view {
	height: var(--status-bar-height);
	width: 100%;
	position: fixed;
	background-color: #fff;
	top: 0;
	z-index: 999;
}

.fiexd-top {
	width: 100%;
	position: fixed;
	z-index: 99999;
}
.fiexd-top {
	width: 100%;
	position: fixed;
	z-index: 99999;
}

.header {
	display: flex;
	flex-direction: row;
	align-items: center;
	justify-content: space-between;
	background-color: #249af6;
	padding: 55upx 30upx 25upx 30upx;

	.arrow {
		image {
			width: 22upx;
			height: 40upx;
			margin: 4upx 0 0 18upx;
		}
	}
}
.tipBox {
	padding: 30upx;
}
.listBox {
	background-color: $white-background;
	.list-item {
		border-bottom: 2upx #eee solid;
		padding: 40upx 30upx;
		display: flex;
		flex-direction: row;
		align-items: center;
		.text {
			.name {
				margin-bottom: 20upx;
			}
		}
		.checkbox {
			image {
				width: 50upx;
				height: 50upx;
				margin-right: 35upx;
				vertical-align: middle;
			}
		}
	}
}
</style>
